#!/bin/bash
## Platform:All Linux Based Platform
## author:Long Tao
## version:1.0
## description:This is qudan-before project build script
## Company:QuDan
time=`date '+%Y-%m-%d-%H-%M-%S'`
echo $time
fileName=quwan
bakPath=/opt/code/bak
tomcatWebapps=/home/app/tomcat8.5/webapps/
echo "备份文件：" $bakPath

yarn -v
yarn
export CI=false
yarn build

# 判断bak文件夹是否存在,不存在返回1，存在返回0
is_bak_exist(){
  if [ ! -d $bakPath ];then
      return 1
  else
      return 0
  fi
}

file_mv(){
  mkdir $bakPath/$time
  mv $fileName $bakPath/$time
  cp -r $bakPath/$time/$fileName $tomcatWebapps
}

is_bak_exist
if [ $? -eq "0" ]; then
     file_mv
    else
      mkdir $bakPath
      file_mv
fi


